package com.dgut.common.utils;

import com.dgut.common.enums.OrderEnum;

/**
 * @Author zyq
 * @Date 2022/4/18 10:14
 * @Description TODO
 * @Version 1.0
 **/
public class ConvertUtil {

    /**
     * 分转成元
     */
    public static String fenToYuan(Integer price) {
        if (price == null || Integer.valueOf(0).equals(price)) {
            return "暂无";
        }
        return String.valueOf(Double.valueOf(price)/100.0D);
    }

    /**
     * 克转成千克
     */
    public static String gToKg(Integer weight) {
        if (weight == null || Integer.valueOf(0).equals(weight)) {
            return "暂无";
        }
        return String.valueOf(Double.valueOf(weight)/1000.0D);
    }

    /**
     * 订单状态处理
     */
    public static String getState(Integer state) {
        if (OrderEnum.WAIT_ACCEPT.getCode().equals(state)) {
            return OrderEnum.WAIT_ACCEPT.getMessage();
        }
        if (OrderEnum.WAIT_COLLECT.getCode().equals(state)) {
            return OrderEnum.WAIT_COLLECT.getMessage();
        }
        if (OrderEnum.COLLECTED.getCode().equals(state)) {
            return OrderEnum.COLLECTED.getMessage();
        }
        if (OrderEnum.FINISHED.getCode().equals(state)) {
            return OrderEnum.FINISHED.getMessage();
        }
        if (OrderEnum.CANCELED.getCode().equals(state)) {
            return OrderEnum.CANCELED.getMessage();
        }
        if (OrderEnum.TIME_OUT.getCode().equals(state)) {
            return OrderEnum.TIME_OUT.getMessage();
        }
        return "";
    }
}
